/**
 * 保存字符串数据到本地存储
 */
export const saveStringToLocalStore = (key: string, value: string) => {
    window.localStorage.setItem(key, value);
};

/**
 * 从本地存储中获取字符串数据,如果没有反回""
 */
export const getStringFromLocalStore = (key: string): string => {
   return window.localStorage.getItem(key) ?? "";
};

/**
 * 保存数据到本地存储
 */
export const saveToLocalStore =<T> (key: string, value: T) => {
    window.localStorage.setItem(key, JSON.stringify(value));
};
/**
 * 从本地存储获取数据
 */
export const getFromLocalStore = <T>(key: string): T | null => {
    let value = window.localStorage.getItem(key);
    if(value){
        return JSON.parse(value);
    }
    return null;
};